package com.wie.controller;

import com.wie.domain.dto.AnalysisResultDTO;
import com.wie.domain.entity.Result;
import com.wie.domain.vo.AnalysisResultVO;
import com.wie.service.AnalysisResultService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j

@RestController
@RequestMapping("/analyze")
@CrossOrigin(allowCredentials = "true", allowedHeaders = "true")
public class AnalyzeController {

    @Autowired
    private AnalysisResultService analysisResultService;

    /**
     * 分析数据
     * @param analysisResultDTO
     * @return
     */
    @PostMapping
    public Result<AnalysisResultVO> analyze(@RequestBody AnalysisResultDTO analysisResultDTO) {
        log.info("分析数据：{}", analysisResultDTO);
        String content = analysisResultService.analyzeData(analysisResultDTO);
        AnalysisResultVO analysisResultVO = new AnalysisResultVO().builder()
                .content(content)
                .build();
        return Result.success(analysisResultVO);
    }

}
